<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTableSpreadRecords extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('spread_records', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('spreadid')->default('')->nullable(false)->comment('用户被推广ID');
            $table->integer('uid')->default(0)->nullable(false)->comment('被推广用户ID');
            $table->timestamps();
        });
        DB::statement("alter table `spread_records` comment '推广记录表' ");

        Schema::create('store_records', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('proid')->default(0)->nullable(false)->comment('存储的商品ID');
            $table->integer('uid')->default(0)->nullable(false)->comment('用户ID');
            $table->integer('number')->default(1)->nullable(false)->comment('商品存储数量');
            $table->timestamps();
        });
        DB::statement("alter table `store_records` comment '商品存储记录' ");

        Schema::create('rake_backs', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->tinyInteger('ordertype')->default(0)->nullable(false)->comment('订单类型1为预定订单、2为商品订单');
            $table->string('spreadid')->default('')->nullable(false)->comment('推广用户推广ID');
            $table->unsignedInteger('uid')->default(0)->nullable(false)->comment('被推广用户ID');
            $table->unsignedInteger('orderid')->default(0)->nullable(false)->comment('订单ID');
            $table->unsignedInteger('total')->default(0)->nullable(false)->comment('订单总金额');
            $table->unsignedInteger('number')->default(0)->nullable(false)->comment('返佣金额');
            $table->timestamps();
            $table->engine = 'InnoDB';
        });
        DB::statement("alter table `rake_backs` comment '返佣记录' ");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('spread_records');
        Schema::dropIfExists('store_records');
        Schema::dropIfExists('rake_backs');
    }
}
